package com.cos.demo4.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

/**
 * @author: COS
 * @time: 2021/5/17 17:24
 * @description: 环绕
 */
public class InterceptorAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        System.out.println("环绕前置++++++++++++");
        System.out.println("开始事务");
        //放行
        long time = System.currentTimeMillis();
        Method method = invocation.getMethod();
        Object proceed = invocation.proceed();
        long end = System.currentTimeMillis();
        System.out.println();
        System.out.println("环绕后置++++++++++++");
        System.out.println("提交事务");
        return proceed;
    }
}
